<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/common/common.jspf"%>
<style type="text/css">
.col-sm-3 {
	width: 15%;
	float: left;
	text-align: right;
}

.col-sm-9 {
	width: 85%;
	float: left;
	text-align: left;
}

label[class^="btn btn-default"] {
	margin-top: -4px;
}
</style>
</head>
<body>
	<div class="l_err" style="width: 100%; margin-top: 2px;"></div>
	<form id="form" name="form" class="form-horizontal" method="post" action="${ctx}/wxuser/addEntity.shtml">
		<section class="panel panel-default">
		<div class="panel-body">
		<input type="hidden" name="weixinUserFormMap.isReg" value="1">
		<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">省份</label>
				</div>
				<div class="col-sm-9">
					<select name="weixinUserFormMap.provinceName" class="form-control m-b valid">
						<c:forEach var="record" items="${province }">
							<option value="${record.provinceName }" pid="${record.id }"}>${record.provinceName }</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">城市</label>
				</div>
				<div class="col-sm-9">
					<select name="weixinUserFormMap.cityName" class="form-control m-b valid">
					</select>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">医院</label>
				</div>
				<div class="col-sm-9">
					<input type="text" class="form-control" placeholder="请输入医院名" name="weixinUserFormMap.hospitalName" id="hospitalName">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">姓名</label>
				</div>
				<div class="col-sm-9">
					<input type="text" class="form-control" placeholder="请输入姓名" name="weixinUserFormMap.doctorName" id="doctorName">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">手机</label>
				</div>
				<div class="col-sm-9">
					<input type="text" class="form-control" placeholder="请输入手机" name="weixinUserFormMap.mobile" id="mobile">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-3">
					<label class="control-label">分组</label>
				</div>
				<div class="col-sm-9">
					<select name="weixinUserFormMap.groupId" class="form-control m-b valid">
						<c:forEach var="record" items="${group }">
							<option value="${record.id }">${record.name }</option>
						</c:forEach>
					</select>
				</div>
			</div>
		</div>
		<footer class="panel-footer text-right bg-light lter">
		<button type="submit" class="btn btn-success btn-s-xs">提交</button>
		</footer> </section>
	</form>
	<script type="text/javascript">
	onloadurl();
	</script>
	<script type="text/javascript" src="${ctx}/notebook/notebook_files/bootstrap-filestyle.min.js"></script>
</body>

<script type="text/javascript">
$(function() {
	// 异步加载所有菜单列表
	$("form").validate({
		submitHandler : function(form) {// 必须写在验证前面，否则无法ajax提交
			ly.ajaxSubmit(form,{//验证新增是否成功
				type : "post",
				dataType : "json",
				success : function(data) {
					if (data == "success") {
						layer.confirm('保存成功!是否关闭窗口?', function(index) {
							parent.grid.loadData();
				        	parent.layer.close(parent.pageii);
				        	return false;
						});
					} else {
						layer.alert('保存失败！'+ data, 3);
					}
				}
			});
		},
		rules : {
			"weixinUserFormMap.doctorName" : {
				required : true,
			}
		},
		messages : {
			"weixinUserFormMap.doctorName" : {
				required : "姓名不能为空"
			}
		},
		errorPlacement : function(error, element) {// 自定义提示错误位置
			$(".l_err").css('display', 'block');
			$(".l_err").html(error.html());
		},
		success : function(label) {// 验证通过后
			$(".l_err").css('display', 'none');
		}
	});
	$("select[name='weixinUserFormMap.provinceName']").change(function(){
		var data = CommnUtil.ajax("${ctx}/region/loadCityByProvinceId.shtml",{'provinceId':$("select[name='weixinUserFormMap.provinceName'] option:checked").attr("pid")},"json");
		$("select[name='weixinUserFormMap.cityName']").empty();
		$.each(data,function(i,e){
			$("select[name='weixinUserFormMap.cityName']").append("<option value='" + e.cityName + "'>" + e.cityName + "</option>")
		});
	});
	$("select[name='weixinUserFormMap.provinceName']").change();
});
</script>
</html>